﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using Redboil.Bfp.Core;
using Redboil.Bfp.Dao;
using Redboil.Bfp.Model;
using System.Net;

namespace Redboil.Bfp.Web.Services {
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class SampleService {
        private IUserDao userDao;

        public SampleService() {
            userDao = Container.Instance.Resolve<IUserDao>();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [WebInvoke(UriTemplate = "", Method = "GET", ResponseFormat = WebMessageFormat.Json)]
        //[WebGet(UriTemplate = "", ResponseFormat=WebMessageFormat.Json)]
        public IList<User> GetAllUser() {
            IList<User> userList = new List<User>() {
                new User { Oid = 11111, Account = "111"},
                new User { Oid = 22222, Account = "222"},
                new User { Oid = 33333, Account = "333"},
            };
            return userList;
        }


        [WebGet(UriTemplate = "{Id}", ResponseFormat = WebMessageFormat.Json)]
        public User GetUser(String id) {
            User user = new User() { Oid = 11111, Account = "111" };
            return user;
        }

        [WebInvoke(UriTemplate = "", Method = "POST", RequestFormat = WebMessageFormat.Json)]
        public void Create(User instance) {
            //userDao.CreateUser(instance);
        }

        [WebInvoke(UriTemplate = "", Method = "PUT", RequestFormat = WebMessageFormat.Json)]
        public void Update(User instance) {
            //userDao.CreateUser(instance);
        }

        [WebInvoke(UriTemplate = "{Id}", Method = "DELETE")]
        public void DeleteUserById(String id) {
            //
        }

        [WebInvoke(UriTemplate = "", Method = "DELETE", RequestFormat = WebMessageFormat.Json)]
        public void DeleteUserList(IList<User> userList) {
            //
        }
    }
}